package com.kunchi.platform.service.impl;

import com.kunchi.platform.entity.admin.Company;
import com.kunchi.platform.repository.CompanyRepository;
import com.kunchi.platform.service.CompanyService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by denniszhou on 2017/7/23.
 */
@Service("companyService")
public class CompanyServiceImpl implements CompanyService {

  @Autowired
  CompanyRepository companyRepository;

  @Override
  public Long isAllowed(String name, String password) {
    try {
      return companyRepository.findByNameAndPassword(name, password).getId();
    } catch (NullPointerException e) {
      return null;
    }
  }

  @Override
  public Company save(Company company) {
    return companyRepository.save(company);
  }
}
